package login;

import javax.imageio.ImageIO;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


import javax.swing.*;
public class Accesso extends JFrame implements ActionListener{
	 private JButton a=new JButton("ACCEDI");
	 private JButton r=new JButton("REGISTRATI");
	
	
	 
	 
	    JDialog frame;
	    
	 JLabel immagine=new JLabel();
	 
	    public Accesso() {
	        frame = new JDialog();
	        frame.setModal(true);
	        frame.setLocation(250, 100);
	        frame.setTitle("LOGIN");
			 frame.setSize(900,500);
			 frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
			 ImagePanell panel= new ImagePanell   (new ImageIcon("C:\\Users\\acer\\workspace1\\LaboratorioDiAlgoritmi\\src\\Image\\images4321.jpg").getImage());
		   	 frame.getRootPane().add(panel);
	 
	        // pannello
	        panel.setSize(new Dimension(900,500));
	        panel.setMaximumSize(new Dimension(900,500));
	        panel.setMinimumSize(new Dimension(900,500));
	        panel.setPreferredSize(new Dimension(900,500));
	        panel.setLayout(null);
	      

	        // JLabel
	       
	        
	        
	 
	        // accedi button
	        
	        
	        a.setBounds(680,120, 140,80);
	       a.setBorder(null);
	        a.addActionListener( this);
	        
	        a.setFont(new Font("Impact",Font.TRUETYPE_FONT,16));
	        a.setForeground(new java.awt.Color(14,5,100));
	        a.setBackground(new java.awt.Color(160,90,255));
	        //registrati button
	        r.setBounds(680,280,140,80);
		     r.setBorder(null);
		        r.addActionListener( this);
		        r.setFont(new Font("Impact",Font.TRUETYPE_FONT,16));
		      r.setForeground(new java.awt.Color(14,5,100));
		      r.setBackground(new java.awt.Color(160,90,255));
	 
	        
	 
	        // aggiungo al panello principale
	   
	        panel.add(a);
	        panel.add(r);
	   
	        frame.add(panel);
	        frame.setResizable(false);
	        frame.pack();
	        frame.setVisible(true);
	    
	    
	    }
			
			
			




public static void main(String[]args) {
		 // 
	
	Accesso f=new Accesso();
	f.setTitle("LOGIN");

}







@Override

	public void actionPerformed(ActionEvent ae) {
		if( ae.getSource()==a){
			 
					SwingUtilities.invokeLater(new Runnable() {

						@Override
						public void run() {
							MioLogin inst = new MioLogin();
							inst.setLocationRelativeTo(null);
							inst.setVisible(true);
							inst.setVisible(false);
							
							frame.dispose();
						}
						
					});
		}
		if(ae.getSource()==r){
			SwingUtilities.invokeLater(new Runnable() {

				@Override
				public void run() {
					Registrazione inst = new Registrazione();
					inst.setLocationRelativeTo(null);
					inst.setVisible(true);
					inst.setVisible(false);
					
					frame.dispose();
				}
				
			});
		}
		
			
		
	} 

	
}
